//
// Created by lenovo on 25-5-7.
//
#include "iostream"
using namespace std;
class Person
{
public:
    Person(int age)
    {
        m_age = new int (age);
    }
    int *m_age;
    ~Person()
    {
        if (m_age != NULL)
        {
            delete m_age;
            m_age = NULL;
        }
    }
    Person& operator=(Person &p)
    {
        if (m_age != NULL)
        {
            delete m_age;
            m_age = NULL;
        }
        m_age = new int (*p.m_age);
        return *this;
    }
};
void test01()
{
    Person p1(18);
    Person p2(20);
    p1 = p2;
    cout<<"p1-age："<<*p1.m_age<<endl;
    cout<<"p2-age："<<*p2.m_age<<endl;
}
int main()
{
    test01();
    return 0;
}